#include "head.h"

//开始执行子线程，取任务，无任务等待唤醒
void* thread_main(void* status){
    statu_t* statu = (statu_t*)status;

    while(1){
        int net_fd = 0;
        pthread_mutex_lock(&statu->lock);
        while(statu->pQueue.size == 0){
            //说明队列中无任务，子线程要等待唤醒
            pthread_cond_wait(&statu->cond,&statu->lock);
        }

        net_fd = statu->pQueue.head->net_fd;
        deQueue(&statu->pQueue);
        pthread_mutex_unlock(&statu->lock);

        do_work(net_fd);
        
        close(net_fd);
    }
    return NULL;
}

